guint raw_coordinates : 1;
guint forced_size : 1;
guint emblems_applied : 1;
+ guint is_svg : 1;
/* Cached information if we go ahead and try to load
* the icon.
out:
if (icon_info)
{
+ icon_info->is_svg = (suffix_from_name (icon_info->filename) == ICON_SUFFIX_SVG);
icon_info->desired_size = size;
icon_info->desired_scale = scale;
icon_info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
gboolean scale_only)
{
- int image_width, image_height;
- int scaled_desired_size;
+ gint image_width, image_height, image_size;
+ gint scaled_desired_size;
GdkPixbuf *source_pixbuf;
- gboolean is_svg;
/* First check if we already succeeded have the necessary
* information (or failed earlier)
scaled_desired_size = icon_info->desired_size * icon_info->desired_scale;
- is_svg = FALSE;
- if (G_IS_FILE_ICON (icon_info->loadable))
- {
- GFile *file;
- GFileInfo *file_info;
- const gchar *content_type;
-
- file = g_file_icon_get_file (G_FILE_ICON (icon_info->loadable));
- file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- NULL, NULL);
- if (file_info)
- {
- content_type = g_file_info_get_content_type (file_info);
-
- if (content_type && strcmp (content_type, "image/svg+xml") == 0)
- is_svg = TRUE;
-
- g_object_unref (file_info);
- }
- }
-
/* In many cases, the scale can be determined without actual access
* to the icon file. This is generally true when we have a size
* for the directory where the icon is; the image size doesn't
icon_info->scale = (gdouble) scaled_desired_size / (icon_info->dir_size * icon_info->dir_scale);
}
- if (icon_info->scale >= 0. && scale_only && !is_svg)
+ if (icon_info->scale >= 0. && scale_only && !icon_info->is_svg)
return TRUE;
/* At this point, we need to actually get the icon; either from the
&icon_info->load_error);
if (stream)
{
- if (is_svg)
+ if (icon_info->is_svg)
{
gint size = icon_info->dir_size * icon_info->dir_scale * icon_info->scale;
source_pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
*/
image_width = gdk_pixbuf_get_width (source_pixbuf);
image_height = gdk_pixbuf_get_height (source_pixbuf);
+ image_size = MAX (image_width, image_height);
- if (is_svg)
- {
- gint image_size = MAX (image_width, image_height);
- icon_info->scale = image_size / 1000.;
- }
+ if (icon_info->is_svg)
+ icon_info->scale = image_size / 1000.;
else if (icon_info->scale < 0.0)
{
- gint image_size = MAX (image_width, image_height);
if (image_size > 0)
icon_info->scale = (gdouble)scaled_desired_size / (gdouble)image_size;
else
* extra complexity, we could keep the source pixbuf around
* but not actually scale it until needed.
*/
- if (is_svg)
+ if (icon_info->is_svg)
icon_info->pixbuf = source_pixbuf;
else if (icon_info->scale == 1.0)
icon_info->pixbuf = source_pixbuf;